package ar.edu.unq.wannaplay.utils;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.PropertyModel;

import ar.edu.unq.wannaplay.dtos.ProjectDTO;
import ar.edu.unq.wannaplay.services.ProjectService;

public class ProjectsListView extends WPItemListView<ProjectDTO, ProjectService> {

    private static final long serialVersionUID = 1L;

    public ProjectsListView(final String id, final ProjectService service, final List<String> labels, final Panel panel) {
        super(id, service, labels, service.findAllDTOs(), panel);
        this.setList(service.findAllDTOs());
    }

    @Override
    protected void addLinks(final ListItem<ProjectDTO> item) {
        this.getUser().addProjectsViewLinks(item, this, this.getPanel());
    }

    @Override
    protected void populateItem(final ListItem<ProjectDTO> item) {
        ProjectDTO project = (ProjectDTO) item.getDefaultModelObject();
        item.add(new Label("name", new PropertyModel<ProjectDTO>(project, "name")));
        item.add(new Label("interval", new PropertyModel<ProjectDTO>(project, "interval")));
        item.add(new Label("client", new PropertyModel<ProjectDTO>(project, "client")));
        item.add(new Label("manHour", new PropertyModel<ProjectDTO>(project, "manHour")));
        this.addLinks(item);
    }
}
